var ns;
var app = new Vue({
    el: '#app',
    data: {
      form:{
        //线上结算中心
        onlineSettlementInfo:{
             Amount:0, //线上结算金额
             SettleableAmount:0, //线上可结算金额
             FrozenAmount:0, //冻结金额
             Paymentproportion:0,//支付手续费比例
             PaymentAmount:0  //手续费比例
        },
        //线下结算中心
        offlineSettlementInfo:{
            SettleableAmount:0, //可结算金额
            Paymentproportion:0,//支付手续费比例
            PaymentAmount:0,//支付手续费
        },
        //预计到账金额
        EstimatedAmount:0
      }

    },
methods:{
  get_data:function(){
    var that = this;
    var option={};
    option.action="getmallbusinesssettlement";
    ns.post(option, function(succeed, data, err) {
      if (succeed) {
          //alert(JSON.stringify(data));
           that.form=data;
      }
    });
  },
  open_tixian: function(item) {

        var that = this;
        if(that.form.onlineSettlementInfo.SettleableAmount<=1){
          api.toast({
              msg: '可提现金额不足',
              duration: 1000,
              location: 'bottom'
          });
          return;
        }
        ns.openWin('dl_tixian', '提现申请', {
             Amount:that.form.onlineSettlementInfo.SettleableAmount+that.form.onlineSettlementInfo.PaymentAmount,//提现金额
             cashMoney : that.form.EstimatedAmount, //预计到账金额
             offline_Amount:that.form.offlineSettlementInfo.SettleableAmount+that.form.offlineSettlementInfo.PaymentAmount,
             setBalance:{
               Transfer_Amount:that.form.EstimatedAmount, //转账金额
               OnLine_Transfer_Amount:that.form.onlineSettlementInfo.SettleableAmount+that.form.onlineSettlementInfo.PaymentAmount,//线上转账金额
               OnlineRuleID:that.form.onlineSettlementInfo.ruleid,//线上申请规则ID
               OnlineConvertRate: that.form.onlineSettlementInfo.Paymentproportion,//线上申请手续费比例
               OnlineShouXuFei:that.form.onlineSettlementInfo.PaymentAmount, //支付手续费
               OffLine_Transfer_Amount:that.form.offlineSettlementInfo.SettleableAmount+that.form.offlineSettlementInfo.PaymentAmount,//线下转账金额
               OfflineRuleID:that.form.offlineSettlementInfo.ruleid, //线下申请规则ID
               OfflineConverRate:that.form.offlineSettlementInfo.Paymentproportion,//线下申请手续费比例
             }
        });
      },
    open_jiesuanlist: function() {
        var that = this;
        ns.openWin('dl_jiesuanlist', '结算记录', {
            id: 0,
        });
      },
      //收入统计
      open_incomeReport:function(){
        var that = this;
        ns.openWin('dl_shourutj_frm', '收入统计', {
            id: 0,
        });
      },
  }
});
apiready = function() {
    api.parseTapmode();
    ns = window.Foresight.Util;
    app.get_data();
    api.addEventListener({
        name: 'tixian'
    }, function(ret, err){
      app.get_data();
    });

};
